package com.loongxun.xxapp;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

/**
 * 欢迎界面
 * Created by Administrator on 2017/10/19.
 */
public class StartActivity extends Activity {

    private SharedPreferences share;
    private SharedPreferences.Editor editor;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final View startView = View.inflate(this, R.layout.splash, null);
        setContentView(startView);

        share = getSharedPreferences("userInfo", 0);
        editor = share.edit();

        //渐变
        AlphaAnimation aa = new AlphaAnimation(0.3f, 1.0f);
        aa.setDuration(2000);// 动画时间
        startView.setAnimation(aa);
        aa.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                redirectto();
            }
        });
    }



    private void redirectto() {
        // 判断之前有没有显示过新手引导
        boolean userGuide = share.getBoolean("is_user_guide_showed", false);
        if (!userGuide) {
            // 跳转到新手引导页
//            Intent intent = new Intent(this,GuideActivity.class);
//            startActivity(intent);
//        } else {
            Intent intent = new Intent(this,MainActivity.class);
            startActivity(intent);
        }
        finish();
    }

}
